#define _CRT_SECURE_NO_WARNINGS   1

#include<iostream>
#include<string>
#include<vector>
#include<stack>

using namespace std;

class Solution {
public:
	int evalRPN(vector<string>& tokens)
	{
		stack<int> st;
		for (int i = 0; i<(int)tokens.size(); i++)
		{
			if (tokens[i] == "+" || tokens[i] == "-" || tokens[i] == "*" || tokens[i] == "/")
			{
				int n1 = st.top();
				st.pop();
				int n2 = st.top();
				st.pop();
				if (tokens[i] == "+")st.push(n1 + n2);
				if (tokens[i] == "-")st.push(n2 - n1);
				if (tokens[i] == "*")st.push(n1*n2);
				if (tokens[i] == "/")st.push(n2 / n1);
			}
			else
			{
				int k = stoi(tokens[i]);
				st.push(k);
			}
		}
		return st.top();
	}
};
int main()
{
	Solution  sol;
	string s;
	vector<string>arr;
	while (cin >> s)
	{
		arr.push_back(s);
		if (cin.get() == '\n')
			break;
	}
	cout << sol.evalRPN(arr) << endl;
	return 0;
}